package liangtWorkSpace.threadDemo.MathThrad;

/**
 * @ClassName ThreadAddSub
 * @Description : 功能说明
 * @Author : LiangT
 * @Date : 2020/7/4 18:25
 */
public class ThreadAddSub extends Thread {
    boolean operate = true;
    static int sum = 0;

    public ThreadAddSub(Boolean bo) {
        this.operate = bo;
    }

    @Override
    public void run() {
        super.run();
        while (true) {
            if (operate) {
                sum += 5;
                System.out.println("加后，sum=" + sum);
            } else {
                sum -= 4;
                System.out.println("减后，sum=" + sum);
            }
            try {
                sleep(500);
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }
}
